package com.base.themvx

import android.util.Log

/**
 ******************(^_^)***********************<br>
 * Author: fee(QQ/WeiXin:1176610771)<br>
 * <P>DESC:
 * 简单的 Logcat 控制台输出日志(默认debug App时才输出)
 * </p>
 * ******************(^_^)***********************
 */
class AppLog {
    companion object Helper {

        fun String.logE(tag: String) {
            e(tag,this)
        }
        fun String.logI(tag: String){
            i(tag,this)
        }
        fun String.logW(tag: String) {
            w(tag,this)
        }
        val isDebug = BuildConfig.DEBUG
        var mIsEnable = isDebug

        @JvmStatic
        fun i(tag: String,logMsg: String) {
            i(tag,logMsg,null)
        }

        @JvmStatic
        fun i(tag: String, logMsg: String?, throwable: Throwable?) {
            if (mIsEnable) {
                Log.i(tag, logMsg, throwable)
            }
        }

        @JvmStatic
        fun e(tag: String,logMsg: String){
            e(tag,logMsg, throwable = null)
        }

        @JvmStatic
        fun e(tag: String,logMsg: String?,throwable: Throwable?){
            if (mIsEnable){
                Log.e(tag,logMsg,throwable)
            }
        }

        @JvmStatic
        fun w(tag: String, logMsg: String?) {
            w(tag,logMsg,null)
        }

        @JvmStatic
        fun w(tag: String,logMsg: String?,throwable: Throwable?) {
            if (mIsEnable) {
                Log.w(tag,logMsg,throwable)
            }
        }

        @JvmStatic
        fun d(tag: String,logMsg: String?){
            d(tag,logMsg,null)
        }

        @JvmStatic
        fun d(tag: String,logMsg: String?,throwable: Throwable? = null) {
            if (mIsEnable){
                Log.d(tag,logMsg,throwable)
            }
        }


    }
}